#include <stdio.h>
#include <stdlib.h>

typedef int DataType;

typedef enum bool Bool;
enum bool {
        false, true
};

struct LinearList {
        int Maxnum;
        DataType *element; // 动态存储
        int len;
};
typedef struct LinearList *List;

int cmp(const void *a, const void *b)
{
        if (*(int *)a < *(int *)b)
                return -1;
        return 1;
}

Bool IsEmptyList(List list)
{
        return list->len == 0;
}

void SortDelete(List list)
{
        if (IsEmptyList(list))
                return;
        if (list->len == 1)
                return;
        qsort(list->element, list->len, sizeof(int), cmp);
        int i, j;
        for (i = 1; i < list->len; i++)
                if (list->element[i] > list->element[0])
                        break;
        for (j = list->len - 2; j >= 0; j--)
                if (list->element[j] < list->element[list->len - 1])
                        break;
        j++;
        for (; j < list->len && i < j; j++)
                list->element[i++] = list->element[j];
        list->len = i;
}

List CreateNewList(int m)
{
        // 动态分配一个struct LinearList给list.
        List list = (List)malloc(sizeof(struct LinearList));
        // 为list中的成员变量element动态分配一块长度为m存 储空间.
        list->element = (DataType *)calloc(m, sizeof(DataType));
        list->len = m;
        list->Maxnum = 100;
        return list;
}

void fuzhi(List list)
{
        list->element[0] = 0;
        list->element[1] = 2;
        list->element[2] = 4;
        list->element[3] = 5;
        list->element[4] = 6;
        list->element[5] = 7;
        list->element[6] = 9;
        list->element[7] = 9;
}

void print_all(List list)
{
        for (int i = 0; i < list->len; i++) {
                printf("%d ", list->element[i]);
        }
        printf("\n");
}

int main()
{
        int n;
        scanf("%d", &n);
        List list = CreateNewList(n);
        print_all(list);
        fuzhi(list);
        print_all(list);
        SortDelete(list);
        print_all(list);
        return 0;
}
